package com.opensource.component.query.method;

import com.baomidou.mybatisplus.core.metadata.TableInfo;
import com.opensource.component.query.script.ExtendMybatisCommand;
import com.opensource.component.query.script.MybatisCommand;

/**
 * @author ZonLen since on 2021/12/18 下午5:14
 */
public class ClickhouseExtendUpdate extends AbstractExtendMethod {

  @Override
  public String sqlFormat(TableInfo tableInfo) {
    final String sqlSetScript = convertIfEwParam(U_WRAPPER_SQL_SET, false);
    return String.format(sqlCommandType().getSql(), tableInfo.getTableName(), sqlSetScript,
        sqlWhereEntityWrapper(true, tableInfo), sqlComment());
  }

  @Override
  public MybatisCommand sqlCommandType() {
    return ExtendMybatisCommand.CLICKHOUSE_UPDATE_EXTEND;
  }
}